package com.dnjn.happiness.emo.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.emo.api.RemoteHlbeanTypeService;
import com.dnjn.happiness.emo.api.RemoteUserRecordFerService;
import com.dnjn.happiness.emo.api.model.HlbeanTypeVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteUserRecordFerFallbackFactory implements FallbackFactory<RemoteUserRecordFerService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteUserRecordFerFallbackFactory.class);

    @Override
    public RemoteUserRecordFerService create(Throwable throwable) {
        log.error("调用AI情绪服务失败：{}" + throwable.getMessage());
        return new RemoteUserRecordFerService() {
            @Override
            public R<Double> getAIHappinessScores(Long userId,String time, String source) {
                return R.fail("查询用户AI情绪记录失败：{}" + throwable.getMessage());
            }

            @Override
            public R<Boolean> hasClockInToday(Long userId, String source) {
                return R.fail("查询用户是否打卡失败：{}" + throwable.getMessage());
            }
        };
    }
}
